﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CWB.Web;

namespace CWB.WebSite.ToolPages
{
    public partial class knock : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsValidRequest())
            {
                Session["EnableToolPage"] = true;
            }
            else
            {
                Session["EnableToolPage"] = null;
                this.EndRequest();
            }
        }

        private bool IsValidRequest()
        {
            Trading t = (Trading)Session[SessionData.TradingSessionKey];
            if (t != null)
            {
                if (t.userName != null && t.userName.ToLower() == "roy")
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
            else
            {
                return false;
            }
        }

        private void EndRequest()
        {
            Response.Redirect("~/Views/Shared/Error.aspx", true);
            Response.StatusCode = 404;
            Response.End();
        }
    }
}
